package org.finesys.system.api.feignFactory;

import org.finesys.common.core.module.R;
import org.finesys.system.api.dto.SysUserDTO;
import org.finesys.system.api.dto.UserInfo;
import org.finesys.system.api.feign.UserServiceApi;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;


@Component
@ConditionalOnProperty(name = "feign.enabled", havingValue = "true")
public class UserServiceApiFallbackFactory implements FallbackFactory<UserServiceApi> {

    @Override
    public UserServiceApi create(Throwable cause) {
        return new UserServiceApi() {
            @Override
            public R<UserInfo> info(SysUserDTO sysUserDTO) {
                return R.failed("获取用户信息失败:" + cause.getMessage());
            }
        };
    }
}
